package com.jysz.certificate.persistence.model.workflow;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.jysz.certificate.persistence.enums.WorkflowOperateType;
import com.jysz.certificate.persistence.model.system.User;
import com.jysz.webcore.ssh.entity.AbstractBaseEntity;

/**
 * 流程操作记录
 * @author xuxiaolong
 */
@Entity
@Table(name = "wf_operate_")
@org.hibernate.annotations.Entity
public class WorkflowOperate extends AbstractBaseEntity<Long> {

	
	private static final long serialVersionUID = -7757704345848348078L;
	
	/** 所属流程*/
	private Workflow workflow;
	
	/** 操作人*/
	private User operater;
	
	/** 操作类型*/
	private WorkflowOperateType type;
	
	/** 描述*/
	private String description;
	
	/** 操作时间*/
	private Date operateDate;
	
	public WorkflowOperate(){};
	public WorkflowOperate(Workflow wf,User user,WorkflowOperateType type,String msg){
		this.workflow=wf;
		this.operater=user;
		this.type=type;
		this.description=msg;
		this.operateDate=new Date();
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_workflow_id", insertable=true, updatable=true,columnDefinition="bigint(20)")
	@Type(type="Long")
	public Workflow getWorkflow() {
		return workflow;
	}

	public void setWorkflow(Workflow workflow) {
		this.workflow = workflow;
	}

	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="_operater", insertable=true, updatable=true,columnDefinition="bigint(20)")
	public User getOperater() {
		return operater;
	}

	public void setOperater(User operater) {
		this.operater = operater;
	}
	
	@Column(name = "_type", nullable = false,columnDefinition="int(11)")
	public WorkflowOperateType getType() {
		return type;
	}

	public void setType(WorkflowOperateType type) {
		this.type = type;
	}

	@Column(name = "_description",columnDefinition="varchar(255)")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "_operate_date", nullable = false)
	public Date getOperateDate() {
		return operateDate;
	}

	public void setOperateDate(Date operateDate) {
		this.operateDate = operateDate;
	}
	

}
